package com.ultrawise.survey.module.surevybase.dao;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Repository;

import com.ultrawise.survey.core.Page;
import com.ultrawise.survey.core.base.BaseDao;
import com.ultrawise.survey.core.base.Saveable;
import com.ultrawise.survey.module.surevybase.vo.TSurveyInfoObjtable;

/**
 * A data access object (DAO) providing persistence and search support for
 * TSurveyInfoObjtable entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see AbstractTSurveyInfoObjtable.dao.TSurveyInfoObjtable
 * @author MyEclipse Persistence Tools
 */
@Repository("tSurveyInfoObjtableDAO")
public class TSurveyInfoObjtableDAO extends BaseDao {
	private static final Logger log = LoggerFactory
			.getLogger(TSurveyInfoObjtableDAO.class);

	// property constants

	public TSurveyInfoQuestionDAO getTSurveyInfoQuestionDAO() {
		return null;
	}

	public Page<TSurveyInfoObjtable> getlistpage1(int start, int limel,
			TSurveyInfoObjtable tobj) {
		return null;
	}

	public List<TSurveyInfoObjtable> getBySyidOrder(String colunm, String value) {
		String sql = "select * from T_SURVEY_INFO_OBJTABLE where " + colunm
				+ "=? and OB_ISUSE=0 ";
		sql += " order by OB_ORDER ";
		return getJdbcTemplate().query(sql,
				new BeanPropertyRowMapper(TSurveyInfoObjtable.class), value);
	}
	
	//查询是否有对象表。
	public boolean isExitTable(Integer syid){
		String sql="show tables like 't_survey_obj"+syid+"'";
		List<Map<String,Object>> rs=queryBysql(sql);
		
		if (rs != null && rs.size() > 0) {
			Map<String, Object> mp = rs.get(0);
			if (mp != null && mp.size() > 0) {
				return true;
			}
		}
		return false;
	}
	@Override
	public List findByColunm(String colunm, String value, Saveable objForSave,
			Class obj) {
		String sql = "select * from " + objForSave.getTableName() + " where "
				+ colunm + "=?  and OB_ISUSE=0 ";
		return getJdbcTemplate().query(sql, new BeanPropertyRowMapper(obj),
				value);
	}
}